const url = process.env.VUE_APP_BASE_URL;
const setLocal = (key,value,expire) => {
	let obj = {};
	let timestamp = Date.parse(new Date())/1000;
	obj.name = value;
	obj[key+'_expire'] = expire ? Number(expire) + timestamp : 0;
	localStorage.setItem(key,JSON.stringify(obj));
}
const getLocal = (key) => {
	let s = JSON.parse(localStorage.getItem(key));
	let timestamp = Date.parse(new Date())/1000;
	if(!s){
		return false;
	}else{
		let expire = s[key+'_expire'];
		if(expire == 0 || expire > timestamp){
			return s.name;
		}else{
			localStorage.removeItem(key);
			return false;
		}
	}
}
export default {
  url,setLocal,getLocal
};